package 课堂练习;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

//需求：
//有2个数组，第一个数组内容为：[黑龙江省,浙江省,江西省,广东省,福建省]，
//第二个数组为：[哈尔滨,杭州,南昌,广州,福州]，
//最终显示效果: 如{黑龙江省=哈尔滨, 浙江省=杭州, …}
public class Test1 {
    public static void main(String[] args) {
        String[] arr1 = {"黑龙江省","浙江省","江西省","广东省","福建省"};
        String[] arr2 = {"哈尔滨","杭州","南昌","广州","福州"};
        Map<String, String> map = new HashMap<>();
        for (int i = 0; i < 5; i++) {
            String key = arr1[i];
            String value = arr2[i];
            map.put(key,value);
        }
        System.out.print("{");
        Set<Map.Entry<String, String>> entry = map.entrySet();
        for (Map.Entry entry1 : entry) {
            //获取key: getKey()
            //获取value: getValue()
            Object key = entry1.getKey();
            Object value = entry1.getValue();
            System.out.print(" "+key + "=" + value+" ");
        }
        System.out.print("}");
    }
}
